function score = seeNeuralNetworkPlayGUI(weights, pieces)

import javax.swing.*;
import hr.fer.zesoi.neumre.*;

path = 'board.jar';
width = 220;
height = 650;
delay = 100;

javarmpath(path);
javaclasspath(path);

tableHeight = 12;
tableWidth = 6;
pieceNum = length(pieces);

visualizer = TetrisVisualizer(width, height, tableHeight, tableWidth, delay);

table = zeros(tableHeight, tableWidth);
score = 0;

while true
    piece = pieces(randi(pieceNum));

    [inputs, tables, moveScores, ~, legalMoves] = formInputs(table, piece);
    quality = predictQuality(weights, inputs);
    
    [~, bestInd] = max(quality);
    
    table = tables{bestInd};
    position = legalMoves(1, bestInd) - 1;
    rotation = legalMoves(2, bestInd);
    if moveScores(bestInd) ~= -800
        score = score + moveScores(bestInd);
    end

    visualizer.showMove(piece - 1, position, rotation, score);
    
    if moveScores(bestInd) == -800
        break;
    end
    pause(1.5);
end

visualizer.close();

